package org.example;

public class Test2 {
    //leetcode 26 删除有序数组中重复项 https://leetcode.cn/problems/remove-duplicates-from-sorted-array/description/
    public int removeDuplicates(int[] nums) {
        int n = nums.length;
        if (n == 1) return 1;
        int slow = 0, fast = 1, ret = n;
        while (fast < n) {
            if (nums[slow] != nums[fast]) {
                nums[++slow] = nums[fast];
            }else {
                ret--;
            }
            fast++;
        }
        return ret;
    }
}
